package cn.lstf666.springboot.web;

import cn.lstf666.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class indexController {

    @RequestMapping("/user/detail")
    public String message(Model model){
        model.addAttribute("data","springboot集成Thymeleaf");
        return "message";
    }

    @RequestMapping(value = "/thymeleaf/user")
    public String user(Model model) {
        User user = new User();
        user.setId(1);
        user.setName("张三");
        user.setPhone("13700000000");
        user.setAddress("北京市亦庄经济开发区");
        model.addAttribute("user",user);
        return "user";
    }


    @RequestMapping(value = "/url/url")
    public String urlExpression(Model model) {
        model.addAttribute("id",1001);
        model.addAttribute("name","wyg");
        model.addAttribute("age",10);
        return "url";
    }

    @RequestMapping(value = "/test")
    public @ResponseBody  String urlExpression1(Integer id,String name,Integer age) {

        return "请求路径/test,参数id="+id+"username="+name+"age="+age;
    }

}
